Popular Searches
Popular Course Categories
Popular Courses

Framework Architecture

Framework Architecture

Test Automation Framework

Framework Architecture in Selenium

Framework Architecture in Selenium defines the overall structure, organization, and interaction of different components used to build a maintainable, reusable, scalable, and reliable automation testing framework. Instead of writing all Selenium code directly inside individual test cases, a framework separates responsibilities such as test execution, page objects, WebDriver management, test data, configuration, utilities, reporting, logging, screenshots, and CI/CD.

A well-designed Selenium framework helps automation engineers reduce code duplication, improve maintainability, simplify debugging, support multiple browsers, execute tests in parallel, manage test data, generate reports, and integrate automated tests into CI/CD pipelines.

JustAcademy's Selenium training curriculum includes Selenium WebDriver, TestNG, Data-Driven Testing, Page Object Model, Automation Framework concepts, Keyword-Driven Framework, Hybrid Framework Design, Reusable Test Architecture, Reporting, Logging, Debugging, Selenium Grid, Cross-Browser Testing, and CI/CD. These topics are important building blocks for understanding real-world Selenium framework architecture.

Selenium Training | Register for Course Demo


1. What Is Framework Architecture?

Framework Architecture is the structural design of an automation project that defines how different components communicate and work together.

In a Selenium automation framework, these components may include:

  • Test classes
  • TestNG
  • Page Object Model
  • Page Factory
  • WebDriver
  • Driver Factory
  • Base Test
  • Base Page
  • Configuration files
  • Test data
  • Utility classes
  • Wait mechanisms
  • Listeners
  • Logging
  • Reporting
  • Screenshots
  • Selenium Grid
  • Maven
  • Git
  • Jenkins and CI/CD


2. Simple Definition

Selenium Framework Architecture is an organized structure that separates automation responsibilities into reusable components so that Selenium tests can be developed, executed, maintained, and scaled efficiently.


3. Why Do We Need Framework Architecture?

Suppose an automation team has only one test case. A simple Selenium script may be enough:

WebDriver driver = new ChromeDriver();

driver.get("https://example.com");

 

driver.findElement(By.id("username")).sendKeys("admin");

driver.findElement(By.id("password")).sendKeys("admin123");

driver.findElement(By.id("login")).click();

This approach becomes difficult when the project contains hundreds of test cases.

Without a proper architecture:

  • Browser setup gets duplicated.
  • Locators are repeated in multiple test cases.
  • Test data becomes difficult to manage.
  • Changing a locator requires multiple modifications.
  • Reports become difficult to maintain.
  • Debugging becomes harder.
  • Parallel execution becomes complicated.
  • Cross-browser testing becomes difficult.
  • CI/CD integration becomes difficult.
  • Multiple testers cannot easily maintain the project.


4. Main Objectives of Framework Architecture

  • Maintainability
  • Reusability
  • Scalability
  • Readability
  • Reliability
  • Test execution management
  • Centralized configuration
  • Centralized driver management
  • Test-data management
  • Reporting
  • Logging
  • Error handling
  • Screenshot capture
  • Parallel execution
  • Cross-browser testing
  • CI/CD integration


5. Basic Selenium Framework Architecture

                    Selenium Automation Framework

                               |

        +----------------------+----------------------+

        |                      |                      |

     Test Layer           Page Layer             Data Layer

        |                      |                      |

     TestNG               Page Objects          Excel / CSV

        |                      |                  JSON / DB

        +----------------------+----------------------+

                               |

                         Utility Layer

                               |

          +--------------------+--------------------+

          |                    |                    |

       Waits              Screenshots            Files

          |                    |                    |

          +--------------------+--------------------+

                               |

                       Driver Management

                               |

                         WebDriver

                               |

                            Browser

                               |

                       Web Application


6. High-Level Framework Flow

TestNG / Test Runner

        ↓

Test Class

        ↓

Page Object

        ↓

Page Methods

        ↓

Selenium WebDriver

        ↓

Browser

        ↓

Web Application

        ↓

Assertions

        ↓

Test Result

        ↓

Report / Log / Screenshot


7. Main Layers of Selenium Framework

LayerPurpose
Test LayerContains test scenarios and validations.
Page LayerContains page locators and page actions.
Base LayerContains common test/page functionality.
Driver LayerCreates and manages WebDriver instances.
Data LayerManages external and internal test data.
Configuration LayerStores browser, URL, timeout, and environment settings.
Utility LayerProvides reusable helper methods.
Listener LayerHandles test execution events.
Reporting LayerGenerates test execution reports.
Logging LayerRecords execution details and errors.
CI/CD LayerAutomates build and test execution.


8. Separation of Concerns

One of the most important principles of framework architecture is Separation of Concerns.

Each component should have a specific responsibility.

Test Class

→ What should be tested?

 

Page Object

→ How should the page be operated?

 

Driver Factory

→ Which browser should be started?

 

Config Reader

→ Which configuration should be loaded?

 

Data Utility

→ Where should test data come from?

 

Wait Utility

→ How should synchronization be handled?

 

Report Manager

→ How should test results be displayed?

 

Screenshot Utility

→ How should screenshots be captured?


9. Recommended Selenium Framework Project Structure

SeleniumAutomationFramework

│

├── pom.xml

│

├── src

│   ├── main

│   │   └── java

│   │       ├── base

│   │       │   ├── BasePage.java

│   │       │   └── BaseTest.java

│   │       │

│   │       ├── pages

│   │       │   ├── LoginPage.java

│   │       │   ├── HomePage.java

│   │       │   ├── ProductPage.java

│   │       │   ├── CartPage.java

│   │       │   └── CheckoutPage.java

│   │       │

│   │       ├── factory

│   │       │   └── DriverFactory.java

│   │       │

│   │       ├── utilities

│   │       │   ├── WaitUtil.java

│   │       │   ├── ExcelUtil.java

│   │       │   ├── ScreenshotUtil.java

│   │       │   ├── ConfigReader.java

│   │       │   └── JavaScriptUtil.java

│   │       │

│   │       ├── listeners

│   │       │   └── TestListener.java

│   │       │

│   │       └── reports

│   │           └── ReportManager.java

│   │

│   └── test

│       ├── java

│       │   └── tests

│       │       ├── LoginTest.java

│       │       ├── ProductTest.java

│       │       ├── CartTest.java

│       │       └── CheckoutTest.java

│       │

│       └── resources

│           ├── config.properties

│           ├── testdata.xlsx

│           └── testng.xml

│

├── screenshots

├── reports

└── logs


10. Test Layer

The Test Layer contains actual test scenarios. It should focus on describing what needs to be tested rather than containing every low-level Selenium command.

Typical test classes include:

  • LoginTest
  • RegistrationTest
  • SearchTest
  • ProductTest
  • CartTest
  • CheckoutTest
  • ProfileTest
  • OrderTest


11. Example Test Class

public class LoginTest extends BaseTest {

 

    @Test

    public void validLoginTest() {

 

        LoginPage loginPage =

            new LoginPage(driver);

 

        loginPage.login(

            "admin",

            "admin123"

        );

 

        Assert.assertTrue(

            loginPage.isLoginSuccessful()

        );

    }

}


12. Page Object Layer

The Page Object layer represents application pages or reusable UI components as classes.

Examples:

LoginPage

HomePage

ProductPage

CartPage

CheckoutPage

OrderConfirmationPage

A Page Object normally contains:

  • Locators
  • Page-specific actions
  • Validation methods
  • Navigation methods
  • Reusable page behavior


13. Page Object Example

public class LoginPage {

 

    private WebDriver driver;

 

    private By username =

        By.id("username");

 

    private By password =

        By.id("password");

 

    private By loginButton =

        By.id("login");

 

    public LoginPage(WebDriver driver) {

        this.driver = driver;

    }

 

    public void enterUsername(String value) {

        driver.findElement(username)

              .sendKeys(value);

    }

 

    public void enterPassword(String value) {

        driver.findElement(password)

              .sendKeys(value);

    }

 

    public void clickLogin() {

        driver.findElement(loginButton)

              .click();

    }

 

    public void login(

            String user,

            String pass) {

 

        enterUsername(user);

        enterPassword(pass);

        clickLogin();

    }

}


14. Page Factory in Framework Architecture

Page Factory can be used as an implementation approach within the Page Object layer. It is important to understand that Page Factory is not the complete framework architecture. POM is the design pattern, while Page Factory is one traditional approach for representing and initializing page elements.

Test Class

     ↓

LoginPage

     ↓

@FindBy

     ↓

PageFactory.initElements()

     ↓

WebElement

     ↓

WebDriver

     ↓

Browser


15. BaseTest Layer

BaseTest contains common test lifecycle operations shared by multiple test classes.

Typical responsibilities include:

  • Browser initialization
  • Application launch
  • Browser configuration
  • Test setup
  • Test cleanup
  • Driver shutdown


16. BaseTest Example

public class BaseTest {

 

    protected WebDriver driver;

 

    @BeforeMethod

    public void setUp() {

 

        driver = new ChromeDriver();

 

        driver.manage()

              .window()

              .maximize();

 

        driver.get(

            "https://example.com"

        );

    }

 

    @AfterMethod

    public void tearDown() {

 

        if (driver != null) {

            driver.quit();

        }

    }

}


17. Driver Factory

A Driver Factory centralizes WebDriver creation.

Instead of creating browsers directly in every test class, the framework can use one common component.

Test

 ↓

DriverFactory

 ↓

Browser Selection

 ↓

Chrome / Firefox / Edge

 ↓

WebDriver Instance


18. Driver Factory Example

public class DriverFactory {

 

    public static WebDriver createDriver(

            String browser) {

 

        if (browser.equalsIgnoreCase("chrome")) {

            return new ChromeDriver();

        }

 

        if (browser.equalsIgnoreCase("firefox")) {

            return new FirefoxDriver();

        }

 

        if (browser.equalsIgnoreCase("edge")) {

            return new EdgeDriver();

        }

 

        throw new IllegalArgumentException(

            "Unsupported browser: " + browser

        );

    }

}


19. Driver Management Flow

Configuration

      ↓

Browser = chrome

      ↓

DriverFactory

      ↓

ChromeDriver

      ↓

WebDriver

      ↓

Test Execution


20. Configuration Layer

Configuration values should be centralized instead of being repeated throughout the project.

Typical configuration values include:

  • Browser
  • Application URL
  • Environment
  • Timeout
  • Headless mode
  • Remote execution URL
  • Screenshot settings


21. config.properties Example

browser=chrome

url=https://example.com

timeout=10

environment=qa

headless=false


22. Configuration Reader

public class ConfigReader {

 

    private static Properties properties;

 

    static {

        properties = new Properties();

 

        try (FileInputStream file =

                new FileInputStream(

                    "src/test/resources/config.properties")) {

 

            properties.load(file);

 

        } catch (IOException e) {

 

            throw new RuntimeException(

                "Unable to load configuration",

                e

            );

        }

    }

 

    public static String get(String key) {

        return properties.getProperty(key);

    }

}


23. Test Data Layer

The Test Data Layer manages the input data required by test cases.

Test data can be stored in:

  • Java objects
  • TestNG DataProvider
  • Excel
  • CSV
  • JSON
  • Database
  • Properties files
  • API responses


24. Data-Driven Architecture

Excel / CSV / JSON

        ↓

Data Utility

        ↓

DataProvider

        ↓

Test Class

        ↓

Page Object

        ↓

Web Application


25. TestNG DataProvider Example

@DataProvider(name = "loginData")

public Object[][] loginData() {

 

    return new Object[][] {

        {"admin", "admin123"},

        {"user1", "password1"},

        {"user2", "password2"}

    };

}

 

@Test(dataProvider = "loginData")

public void loginTest(

        String username,

        String password) {

 

    LoginPage loginPage =

        new LoginPage(driver);

 

    loginPage.login(

        username,

        password

    );

}


26. Utility Layer

Utility classes contain reusable operations that can be used by multiple tests and pages.

Common utilities include:

  • WaitUtil
  • ExcelUtil
  • ScreenshotUtil
  • ConfigReader
  • DateUtil
  • FileUtil
  • JavaScriptUtil
  • BrowserUtil


27. Wait Utility

Synchronization is an important part of a Selenium framework because modern web applications often load elements dynamically.

public class WaitUtil {

 

    private WebDriverWait wait;

 

    public WaitUtil(WebDriver driver) {

 

        wait = new WebDriverWait(

            driver,

            Duration.ofSeconds(10)

        );

    }

 

    public void waitForVisible(

            WebElement element) {

 

        wait.until(

            ExpectedConditions.visibilityOf(element)

        );

    }

 

    public void waitForClickable(

            WebElement element) {

 

        wait.until(

            ExpectedConditions.elementToBeClickable(element)

        );

    }

}


28. Why Avoid Excessive Thread.sleep()?

Thread.sleep() pauses execution for a fixed amount of time regardless of whether the element is already ready.

Explicit waits are generally more suitable for condition-based synchronization.

Thread.sleep(5000);

 

vs.

 

wait.until(

    ExpectedConditions.elementToBeClickable(button)

);


29. Screenshot Utility

public class ScreenshotUtil {

 

    public static void capture(

            WebDriver driver,

            String fileName) {

 

        File source =

            ((TakesScreenshot) driver)

            .getScreenshotAs(OutputType.FILE);

 

        File destination =

            new File(

                "screenshots/"

                + fileName

                + ".png"

            );

 

        try {

            Files.copy(

                source.toPath(),

                destination.toPath()

            );

        } catch (IOException e) {

            throw new RuntimeException(e);

        }

    }

}


30. Reporting Layer

The Reporting Layer records test execution results and provides a readable representation of automation results.

A report can contain:

  • Test name
  • Test status
  • Execution time
  • Failure reason
  • Screenshot
  • Browser information
  • Environment information
  • Logs

Common reporting solutions used with Java automation include TestNG reports, ExtentReports, and Allure.


31. Reporting Flow

Test Starts

    ↓

Test Executes

    ↓

PASS / FAIL / SKIP

    ↓

Listener

    ↓

Report Manager

    ↓

HTML / Dashboard Report


32. Logging Layer

Logging provides information about what happened during test execution.

INFO  - Browser started

INFO  - Application opened

INFO  - Login page loaded

INFO  - Username entered

INFO  - Password entered

INFO  - Login button clicked

INFO  - Dashboard verified

INFO  - Test completed

Log4j is one commonly used logging solution in Java automation projects.


33. Listener Layer

TestNG listeners can react to test lifecycle events.

Common events include:

  • Test started
  • Test passed
  • Test failed
  • Test skipped
  • Suite started
  • Suite finished


34. Listener Architecture

TestNG

  |

  +-- onStart()

  |

  +-- onTestStart()

  |

  +-- onTestSuccess()

  |

  +-- onTestFailure()

  |

  +-- onTestSkipped()

  |

  +-- onFinish()


35. Failure Handling Architecture

Test Failure

     ↓

Listener

     ↓

Capture Screenshot

     ↓

Write Log

     ↓

Update Report

     ↓

Mark Test Failed


36. Maven Layer

Maven is commonly used to manage dependencies, build the project, and execute tests.

A Selenium project may include dependencies such as:

  • Selenium Java
  • TestNG
  • Apache POI
  • Logging libraries
  • Reporting libraries


37. Maven Project Configuration

<project>

    <modelVersion>4.0.0</modelVersion>

 

    <groupId>com.example</groupId>

    <artifactId>selenium-framework</artifactId>

    <version>1.0</version>

 

    <dependencies>

 

        <dependency>

            <groupId>org.seleniumhq.selenium</groupId>

            <artifactId>selenium-java</artifactId>

            <version>YOUR_VERSION</version>

        </dependency>

 

        <dependency>

            <groupId>org.testng</groupId>

            <artifactId>testng</artifactId>

            <version>YOUR_VERSION</version>

            <scope>test</scope>

        </dependency>

 

    </dependencies>

</project>


38. TestNG Layer

TestNG provides test execution and test-management features.

Important features include:

  • @Test
  • @BeforeMethod
  • @AfterMethod
  • @BeforeClass
  • @AfterClass
  • Assertions
  • DataProvider
  • Groups
  • Dependencies
  • Listeners
  • Parallel execution


39. TestNG Execution Flow

testng.xml

     ↓

Test Suite

     ↓

Test Class

     ↓

@BeforeMethod

     ↓

@Test

     ↓

Assertions

     ↓

@AfterMethod

     ↓

Listener

     ↓

Report


40. testng.xml Example

<?xml version="1.0" encoding="UTF-8"?>

 

<!DOCTYPE suite SYSTEM

    "https://testng.org/testng-1.0.dtd">

 

<suite name="AutomationSuite">

 

    <test name="LoginTests">

 

        <classes>

            <class name="tests.LoginTest"/>

        </classes>

 

    </test>

 

</suite>


41. Test Groups

TestNG groups can organize tests according to their purpose.

Smoke

Regression

Sanity

Functional

Critical

EndToEnd

Example:

@Test(groups = {"smoke"})

public void loginTest() {

    // test logic

}


42. Smoke Test Architecture

New Build

   ↓

Smoke Suite

   ↓

Login

Search

Navigation

Critical Features

   ↓

PASS

   ↓

Continue Testing


43. Regression Framework Architecture

Application Changes

       ↓

Regression Suite

       ↓

Test Classes

       ↓

Page Objects

       ↓

WebDriver

       ↓

Browser

       ↓

Assertions

       ↓

Reports


44. Keyword-Driven Framework

A Keyword-Driven Framework represents actions through keywords.

KeywordAction
OPEN_URLOpen application URL.
ENTER_TEXTEnter text.
CLICKClick an element.
SELECTSelect an option.
VERIFY_TEXTVerify text.
SCREENSHOTCapture screenshot.


45. Keyword-Driven Architecture

Test Data

    ↓

Keywords

    ↓

Keyword Engine

    ↓

Utility / Page Methods

    ↓

Selenium WebDriver

    ↓

Browser


46. Hybrid Framework

A Hybrid Framework combines multiple automation approaches and supporting components.

                    Hybrid Framework

                           |

       +-------------------+-------------------+

       |                   |                   |

      POM             Data-Driven       Keyword-Driven

       |                   |                   |

       +-------------------+-------------------+

                           |

                        TestNG

                           |

                       Utilities

                           |

                  Reporting / Logging

                           |

                      CI/CD / Grid


47. Page Object Model and Framework Architecture

Page Object Model separates page-specific UI implementation from test scenarios.

Test Class

    ↓

Page Object

    ↓

Locators + Actions

    ↓

WebDriver

    ↓

Browser

    ↓

Application

This separation helps reduce duplication and makes page-related changes easier to manage.


48. BasePage

A BasePage can provide common operations to different page classes.

public class BasePage {

 

    protected WebDriver driver;

    protected WebDriverWait wait;

 

    public BasePage(WebDriver driver) {

 

        this.driver = driver;

 

        this.wait =

            new WebDriverWait(

                driver,

                Duration.ofSeconds(10)

            );

    }

 

    protected void click(WebElement element) {

 

        wait.until(

            ExpectedConditions.elementToBeClickable(element)

        ).click();

    }

 

    protected void type(

            WebElement element,

            String text) {

 

        wait.until(

            ExpectedConditions.visibilityOf(element)

        );

 

        element.clear();

        element.sendKeys(text);

    }

}


49. Page Factory-Based Page Object

public class LoginPage extends BasePage {

 

    @FindBy(id = "username")

    private WebElement username;

 

    @FindBy(id = "password")

    private WebElement password;

 

    @FindBy(id = "login")

    private WebElement loginButton;

 

    public LoginPage(WebDriver driver) {

 

        super(driver);

 

        PageFactory.initElements(

            driver,

            this

        );

    }

 

    public void login(

            String user,

            String pass) {

 

        type(username, user);

        type(password, pass);

        click(loginButton);

    }

}


50. Thread-Safe Driver Architecture

Parallel execution requires proper driver isolation. Multiple tests should not unintentionally share the same WebDriver instance.

Thread 1 → Driver 1 → Chrome

Thread 2 → Driver 2 → Firefox

Thread 3 → Driver 3 → Edge

ThreadLocal is one technique that can be used for maintaining a driver per execution thread.


51. ThreadLocal Driver Example

public class DriverManager {

 

    private static ThreadLocal<WebDriver> driver =

        new ThreadLocal<>();

 

    public static void setDriver(

            WebDriver webDriver) {

 

        driver.set(webDriver);

    }

 

    public static WebDriver getDriver() {

 

        return driver.get();

    }

 

    public static void unload() {

 

        driver.remove();

    }

}


52. Parallel Execution Architecture

                  Test Suite

                      |

          +-----------+-----------+

          |           |           |

       Thread 1    Thread 2    Thread 3

          |           |           |

       Driver 1    Driver 2    Driver 3

          |           |           |

       Chrome      Firefox      Edge

          |           |           |

          +-----------+-----------+

                      |

                   Results


53. Selenium Grid Architecture

Selenium Grid can be used for remote execution and running tests across different browser environments.

Test Machine

     |

     ↓

Selenium Grid

     |

 +---+---+---+

 |       |   |

Chrome Firefox Edge

 |       |   |

Node 1  Node 2 Node 3


54. Cross-Browser Architecture

                 Test Suite

                     |

                Driver Factory

                     |

       +-------------+-------------+

       |             |             |

     Chrome        Firefox        Edge

       |             |             |

       +-------------+-------------+

                     |

                  Results


55. Environment-Based Architecture

Real-world projects may have multiple environments such as Development, QA, UAT, and Production-like test environments.

Environment

    |

    +-- DEV

    |

    +-- QA

    |

    +-- UAT

    |

    +-- STAGING

The framework can select the target environment using configuration.


56. Environment Configuration

environment=qa

 

qa.url=https://qa.example.com

uat.url=https://uat.example.com

staging.url=https://staging.example.com


57. Component-Based Architecture

Large web applications often contain reusable components such as headers, menus, search boxes, product cards, and footers.

HomePage

   |

   +-- HeaderComponent

   |

   +-- NavigationComponent

   |

   +-- SearchComponent

   |

   +-- ProductComponent

   |

   +-- FooterComponent

Reusable component objects can prevent duplication when the same UI appears across multiple pages.


58. Page Navigation Architecture

LoginPage

    ↓ login()

HomePage

    ↓ openProducts()

ProductPage

    ↓ addToCart()

CartPage

    ↓ checkout()

CheckoutPage

    ↓ placeOrder()

OrderConfirmationPage


59. Fluent Page Object Architecture

A fluent page object can return itself or another page object to create readable workflows.

loginPage

    .enterUsername("admin")

    .enterPassword("admin123")

    .clickLogin();


60. Test Data Management Architecture

Excel / CSV / JSON / Database

             ↓

        Data Utility

             ↓

        Data Provider

             ↓

          Test Class

             ↓

        Page Object

             ↓

        Application


61. Excel-Based Data Architecture

Apache POI is commonly used in Java projects when test data is stored in Excel files.

testdata.xlsx

     ↓

ExcelUtil

     ↓

DataProvider

     ↓

LoginTest

     ↓

LoginPage


62. Screenshot Architecture

Test Failure

     ↓

TestNG Listener

     ↓

Screenshot Utility

     ↓

Capture Browser

     ↓

Save Screenshot

     ↓

Attach to Report


63. Error Handling Architecture

A framework should handle failures in a controlled manner and provide enough information for debugging.

Common failure types include:

  • NoSuchElementException
  • TimeoutException
  • StaleElementReferenceException
  • ElementClickInterceptedException
  • WebDriverException
  • Configuration errors
  • Test-data errors
  • Environment failures


64. Retry Mechanism

A controlled retry mechanism may be used for certain temporary infrastructure or execution failures. It should not be used to hide genuine application defects or consistently unstable tests.

Test

 ↓

Failure

 ↓

Retry Policy

 ↓

Retry

 ↓

Pass / Fail

 ↓

Final Report


65. CI/CD Architecture

Selenium automation can be integrated with CI/CD pipelines so tests can execute automatically after code changes or according to a scheduled pipeline.

Developer

    ↓

Git Commit

    ↓

Git Repository

    ↓

Jenkins / CI Server

    ↓

Maven Build

    ↓

TestNG

    ↓

Selenium

    ↓

Browser / Grid

    ↓

Reports

    ↓

Build Result


66. Git Integration

Git can be used to maintain framework source code and collaborate with other automation engineers.

Common Git activities include:

  • Clone
  • Branch
  • Commit
  • Push
  • Pull
  • Merge
  • Pull Request


67. Jenkins Integration

A Jenkins pipeline can retrieve the framework from source control and execute Maven tests.

Git Checkout

      ↓

Maven Clean

      ↓

Maven Test

      ↓

TestNG

      ↓

Selenium

      ↓

Reports

      ↓

Publish Results


68. Maven Test Execution

mvn clean test

The command can be executed locally or from a CI/CD pipeline depending on the project configuration.


69. CI/CD Parameters

Execution settings can be supplied externally instead of hard-coding them.

BROWSER=chrome

ENVIRONMENT=qa

HEADLESS=true

The framework can read these values and configure the test run accordingly.


70. Logging and Debugging Architecture

Test

 ↓

Action

 ↓

Log Information

 ↓

Failure?

 ↓

Yes → Log Error

 ↓

Capture Screenshot

 ↓

Attach Report

 ↓

Debug


71. Reporting and Logging Relationship

LoggingReporting
Records execution information.Displays test results.
Useful for debugging.Useful for result analysis.
Can contain technical details.Usually provides summarized execution status.
Tracks actions and errors.Tracks PASS/FAIL/SKIP and evidence.


72. Framework Design Principles

Single Responsibility

Each class should have a clear and focused responsibility.

DRY

Don't Repeat Yourself means common implementation should be reused rather than copied.

Encapsulation

Implementation details should remain inside appropriate classes.

Abstraction

Tests should interact with meaningful business-level methods where practical.

Reusability

Common operations should be available to multiple tests.

Maintainability

The framework should be easy to modify when application requirements change.

Scalability

The architecture should support increasing numbers of tests, browsers, environments, and users.


73. DRY Principle Example

Bad architecture:

LoginTest

    → browser setup

 

ProductTest

    → browser setup

 

CheckoutTest

    → browser setup

 

ProfileTest

    → browser setup

Better architecture:

BaseTest / DriverFactory

          ↓

Reusable Browser Setup

          ↓

All Test Classes


74. Encapsulation Example

Instead of exposing page elements directly:

loginPage.username.sendKeys("admin");

use a page method:

loginPage.enterUsername("admin");

This keeps page implementation details inside the page class.


75. Abstraction Example

Instead of placing low-level Selenium operations inside a test:

driver.findElement(

    By.id("username")

).sendKeys("admin");

the test can use:

loginPage.enterUsername("admin");


76. Small Framework vs Enterprise Framework

Small FrameworkLarge/Enterprise Framework
Few testsHundreds or thousands of tests
Basic POMPOM + components
Simple configurationMulti-environment configuration
Local executionGrid/cloud execution
Basic reportingCentralized reporting
Limited utilitiesReusable utility ecosystem
Manual test executionCI/CD execution
Single browserCross-browser execution


77. E-Commerce Framework Architecture

                    E-Commerce Automation

                             |

        +--------------------+--------------------+

        |                    |                    |

      Tests                Pages               Data

        |                    |                    |

 LoginTest              LoginPage             Users

 ProductTest            HomePage              Products

 CartTest               ProductPage           Orders

 CheckoutTest           CartPage

                         CheckoutPage

                              |

                         WebDriver

                              |

                           Browser

                              |

                       E-Commerce App


78. E-Commerce End-to-End Flow

Login

 ↓

Search Product

 ↓

Open Product

 ↓

Add To Cart

 ↓

Open Cart

 ↓

Checkout

 ↓

Enter Address

 ↓

Select Payment

 ↓

Place Order

 ↓

Verify Confirmation


79. Complete Enterprise Framework Architecture

                         CI/CD Pipeline

                              |

                         Git / Maven

                              |

                            TestNG

                              |

                     +--------+--------+

                     |                 |

                Test Classes      Listeners

                     |                 |

                     ↓                 ↓

                Page Objects      Reporting

                     |                 |

             Page Factory / By    Screenshots

                     |                 |

                     +--------+--------+

                              |

                       Driver Factory

                              |

                 +------------+------------+

                 |            |            |

               Chrome       Firefox       Edge

                 |            |            |

                 +------------+------------+

                              |

                       Selenium Grid

                              |

                       Web Application

 

Supporting Components:

Configuration

Test Data

Utilities

Logging

Exception Handling

Database

API Utilities

Constants


80. Complete Framework Execution Flow

Start Test

    ↓

Read Configuration

    ↓

Select Environment

    ↓

Select Browser

    ↓

Driver Factory

    ↓

Create WebDriver

    ↓

Launch Application

    ↓

Initialize Page Objects

    ↓

Execute TestNG Test

    ↓

Call Page Methods

    ↓

Selenium WebDriver

    ↓

Browser

    ↓

Application

    ↓

Assertion

    ↓

PASS / FAIL

    ↓

Listener

    ↓

Screenshot if Required

    ↓

Logging

    ↓

Reporting

    ↓

Driver Quit

    ↓

Final Result


81. Common Framework Mistakes

  • Putting all automation code in one class.
  • Duplicating locators.
  • Duplicating browser setup.
  • Hard-coding URLs everywhere.
  • Hard-coding test data in every test.
  • Using excessive Thread.sleep().
  • Using unstable locators.
  • Making every page field public.
  • Mixing test logic with page implementation.
  • Ignoring screenshots after failures.
  • Not maintaining logs.
  • Sharing one WebDriver instance across parallel tests.
  • Creating one huge utility class for unrelated functionality.
  • Using retry to hide unstable tests.
  • Creating unnecessary abstraction layers.


82. Best Practices

  • Use Page Object Model for page-specific behavior.
  • Keep test classes focused on scenarios and assertions.
  • Centralize browser creation.
  • Centralize configuration.
  • Use stable and meaningful locators.
  • Use condition-based waits.
  • Keep test data separate from test logic.
  • Create reusable utility classes.
  • Capture screenshots for important failures.
  • Maintain useful execution logs.
  • Generate readable reports.
  • Use TestNG groups for test categorization.
  • Use thread-safe driver management for parallel execution.
  • Use Selenium Grid when remote or multi-browser execution is required.
  • Integrate the framework with Git and CI/CD.
  • Keep dependencies compatible and updated.
  • Refactor duplicated or obsolete code.
  • Keep credentials and secrets outside source code.


83. Framework Architecture Checklist

ComponentPurpose
WebDriverBrowser automation.
TestNGTest execution and management.
POMPage organization and maintainability.
Page FactoryTraditional element declaration and initialization approach.
BaseTestCommon test setup and cleanup.
BasePageCommon page operations.
Driver FactoryBrowser driver creation.
Config ReaderConfiguration management.
Data UtilityTest-data management.
Wait UtilitySynchronization.
Screenshot UtilityFailure evidence.
ListenerTest lifecycle handling.
ReportingExecution results.
LoggingExecution tracing and debugging.
Selenium GridRemote and multi-browser execution.
CI/CDAutomated build and test execution.


84. Framework Architecture Interview Questions

Q1. What is a Selenium automation framework?

Answer: A Selenium automation framework is an organized collection of design patterns, utilities, test-management tools, coding practices, and supporting components used to create maintainable and scalable Selenium tests.

Q2. Why do we need framework architecture?

Answer: It separates responsibilities, reduces code duplication, improves maintainability, supports reusable components, and makes execution, reporting, debugging, and scaling easier.

Q3. What is the role of Page Object Model?

Answer: POM separates page-specific UI implementation from test scenarios by representing application pages or components as classes.

Q4. Is Page Factory the complete framework?

Answer: No. Page Factory is an approach that can be used within Page Object classes for element declaration and initialization. The complete framework includes many other components.

Q5. What is Driver Factory?

Answer: Driver Factory is responsible for creating WebDriver instances based on browser or execution configuration.

Q6. What is BaseTest?

Answer: BaseTest is a reusable class that commonly contains common test setup and teardown functionality.

Q7. What is Data-Driven Testing?

Answer: Data-Driven Testing separates test input data from test logic so the same test can execute using multiple data sets.

Q8. What is a Hybrid Framework?

Answer: A Hybrid Framework combines multiple techniques such as POM, data-driven testing, keyword-driven concepts, reusable utilities, TestNG, reporting, and CI/CD.

Q9. How do you handle screenshots?

Answer: A Screenshot Utility can capture screenshots, while a TestNG listener can trigger screenshot capture when tests fail.

Q10. How do you manage multiple browsers?

Answer: Use configuration and a Driver Factory to create the required WebDriver instance for Chrome, Firefox, Edge, or another supported execution environment.


85. Advanced Interview Questions

Q11. How would you design a scalable Selenium framework?

Answer: Separate test, page, driver, configuration, data, utility, listener, reporting, and logging responsibilities. Add thread-safe driver management for parallel execution and integrate the framework with source control and CI/CD.

Q12. How do you support multiple environments?

Answer: Maintain environment-specific configuration and select the required environment through configuration, command-line parameters, or CI/CD variables.

Q13. How do you make parallel execution safe?

Answer: Use independent WebDriver instances per thread and isolate test data so one test does not interfere with another.

Q14. How do you reduce flaky tests?

Answer: Use stable locators, appropriate waits, reliable test data, controlled environment handling, meaningful assertions, and proper cleanup.

Q15. How do you integrate Selenium with Jenkins?

Answer: Store the framework in Git, configure Jenkins to retrieve the project, execute Maven tests, collect reports and screenshots, and publish the results.


86. Practical Project

Project: Build a Selenium automation framework for an e-commerce application.

Project Requirements

  • Java
  • Selenium WebDriver
  • TestNG
  • Maven
  • Page Object Model
  • Page Factory or By-based page objects
  • DataProvider
  • Excel/CSV test data
  • Explicit waits
  • Screenshot utility
  • Logging
  • Reporting
  • Git
  • CI/CD


87. Practical Project Structure

AutomationProject

│

├── base

│   ├── BaseTest.java

│   └── BasePage.java

│

├── factory

│   └── DriverFactory.java

│

├── pages

│   ├── LoginPage.java

│   ├── HomePage.java

│   ├── ProductPage.java

│   ├── CartPage.java

│   └── CheckoutPage.java

│

├── tests

│   ├── LoginTest.java

│   ├── ProductTest.java

│   └── CheckoutTest.java

│

├── utilities

│   ├── ConfigReader.java

│   ├── ExcelUtil.java

│   ├── WaitUtil.java

│   └── ScreenshotUtil.java

│

├── listeners

│   └── TestListener.java

│

├── reports

├── screenshots

├── logs

└── testng.xml


88. Practical Project Execution

Git

 ↓

Jenkins

 ↓

Maven

 ↓

TestNG

 ↓

BaseTest

 ↓

DriverFactory

 ↓

Browser

 ↓

Page Objects

 ↓

Selenium WebDriver

 ↓

Application

 ↓

Assertions

 ↓

Listener

 ↓

Screenshot + Logs

 ↓

Report


89. Framework Architecture Comparison

ApproachStructurePurpose
Basic SeleniumTest + WebDriverSimple scripts and learning.
POMTests + Page ObjectsOrganized page behavior.
POM + Page FactoryTests + Page Objects + @FindByTraditional Page Factory implementation.
Data-DrivenTests + External DataMultiple data combinations.
Keyword-DrivenKeywords + Execution EngineKeyword-based automation.
HybridPOM + Data + Utilities + TestNG + ReportsLarger automation projects.


90. Framework Maintenance

A framework requires continuous maintenance as the application and automation requirements change.

Maintenance activities include:

  • Updating Selenium dependencies.
  • Updating browser-related configuration.
  • Updating changed locators.
  • Removing duplicate code.
  • Improving synchronization.
  • Updating test data.
  • Improving reports.
  • Updating CI/CD configuration.
  • Removing obsolete utilities.
  • Refactoring unstable tests.


91. Framework Code Review Checklist

  • Are locators stable?
  • Is the test readable?
  • Is code duplicated?
  • Are waits appropriate?
  • Is test data isolated?
  • Are exceptions handled properly?
  • Are logs meaningful?
  • Are failure screenshots available?
  • Are sensitive credentials protected?
  • Is the package structure consistent?
  • Are unnecessary dependencies avoided?


92. Framework Security

Automation frameworks may use usernames, passwords, tokens, API keys, or environment-specific information. Sensitive values should not be hard-coded into source code or committed to public repositories.

Prefer:

  • Environment variables
  • CI/CD secret management
  • Secure configuration
  • Masked credentials
  • Dedicated test accounts


93. Quick Revision Table

ConceptMeaning
FrameworkStructured automation system.
ArchitectureOrganization of framework components.
POMDesign pattern for page organization.
Page FactoryTraditional page-element initialization approach.
BaseTestCommon test lifecycle.
BasePageCommon page functionality.
Driver FactoryWebDriver creation.
Config ReaderConfiguration management.
Data UtilityTest-data management.
Wait UtilitySynchronization.
ListenerTest lifecycle event handling.
ReportingTest execution results.
LoggingExecution tracing and debugging.
GridRemote/multi-browser execution.
CI/CDAutomated build and test execution.


94. Most Important Architecture Flow

Configuration

      ↓

Driver Factory

      ↓

WebDriver

      ↓

BaseTest

      ↓

TestNG

      ↓

Test Class

      ↓

Page Object

      ↓

Page Factory / By Locators

      ↓

WebDriver Actions

      ↓

Browser

      ↓

Application

      ↓

Assertions

      ↓

Listener

      ↓

Screenshot

      ↓

Logging

      ↓

Reporting

      ↓

CI/CD


95. Final Summary

Selenium Framework Architecture provides a structured way to organize automation testing projects. Instead of writing browser commands directly inside every test case, the framework separates responsibilities into test classes, page objects, driver management, configuration, test data, utilities, synchronization, listeners, reporting, logging, parallel execution, Selenium Grid, and CI/CD.

Page Object Model provides a strong foundation for organizing page-specific behavior, while Page Factory can be used as one traditional approach for declaring and initializing page elements. TestNG manages test execution, DataProvider supports data-driven execution, Driver Factory manages browser creation, utilities provide reusable functionality, listeners handle execution events, reporting records results, and CI/CD automates test execution.

A good framework architecture should be readable, maintainable, reusable, scalable, reliable, and easy for a team of automation engineers to extend.


96. One-Line Revision

Selenium Framework Architecture is the organized structure that connects tests, page objects, WebDriver, browser management, configuration, test data, utilities, synchronization, reporting, logging, Grid, and CI/CD into a maintainable automation system.


97. Course Resources

Learn Selenium automation, TestNG, Page Object Model, automation framework development, data-driven testing, reporting, Grid, and CI/CD through Selenium Training.

For course enquiry and demo registration, visit Register for Course Demo.


98. Complete Selenium Framework Learning Roadmap

Software Testing

      ↓

Core Java

      ↓

Selenium WebDriver

      ↓

Locators

      ↓

WebElements

      ↓

Waits & Synchronization

      ↓

TestNG

      ↓

Page Object Model

      ↓

Page Factory

      ↓

Data-Driven Testing

      ↓

Keyword-Driven Framework

      ↓

Hybrid Framework

      ↓

Framework Architecture

      ↓

Maven

      ↓

Reporting

      ↓

Logging

      ↓

Screenshots

      ↓

Selenium Grid

      ↓

Cross-Browser Testing

      ↓

Git & GitHub

      ↓

Jenkins

      ↓

CI/CD

      ↓

Real-Time Automation Project

whatsapp